/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package maxent.mr.writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import stanford.tagger.FeatureKey;

/**
 *
 * @author hadoop
 */
public class FeatureKeyWritable implements Writable {

    IntWritable num;
    Text val;
    Text tag;

    public FeatureKeyWritable() {
    }
    

    public FeatureKeyWritable(int num, String val, String tag) {
        this.num = new IntWritable(num);
        this.val = new Text(val);
        this.tag = new Text(tag);
    }

    public FeatureKeyWritable(FeatureKey fk) {
        num = new IntWritable(fk.getNum());
        val = new Text(fk.getVal());
        tag = new Text(fk.getTag());
    }
    

    public void write(DataOutput out) throws IOException {
        num.write(out);
        val.write(out);
        tag.write(out);
    }

    public void readFields(DataInput in) throws IOException {
        num.readFields(in);
        val.readFields(in);
        tag.readFields(in);        
    }

    public IntWritable getNum() {
        return num;
    }

    public Text getTag() {
        return tag;
    }

    public Text getVal() {
        return val;
    }

    

}
